package com.inepex.inegraphics.shared;

import java.util.ArrayList;

public class LinearGradient {

	public class ColorStop{
	
		double stop;
		String color;
		
		public ColorStop(double stop, String color) {
			setStop(stop);
			setColor(color);
		}
		public double getStop() {
			return stop;
		}
		public void setStop(double stop) {
			this.stop = Math.min(1.0, Math.max(0.0, stop));
		}
		public String getColor() {
			return color;
		}
		public void setColor(String color) {
			this.color = color == null ? "black" : color;
		}		
	}
	
	private final ArrayList<ColorStop> colorStops;
	
	private double x0, x1, y0, y1;
		
	public LinearGradient(double x0, double y0, double x1, double y1) {
		colorStops = new ArrayList<LinearGradient.ColorStop>();
		this.x0 = x0;
		this.x1 = x1;
		this.y0 = y0;
		this.y1 = y1;
	}


	public void addColorStop(double stop, String color){
		colorStops.add(new ColorStop(stop, color));
	}
	
	public ArrayList<ColorStop> getColorStops(){
		return colorStops;
	}

	public double getX0() {
		return x0;
	}

	public void setX0(double x0) {
		this.x0 = x0;
	}

	public double getX1() {
		return x1;
	}

	public void setX1(double x1) {
		this.x1 = x1;
	}

	public double getY0() {
		return y0;
	}

	public void setY0(double y0) {
		this.y0 = y0;
	}

	public double getY1() {
		return y1;
	}

	public void setY1(double y1) {
		this.y1 = y1;
	}
	
	
}
